package sisdroid.framework.model;

import java.util.ArrayList;
import java.util.HashSet;

public class InfoPackage
{
	
	
	public InformationData getInfoByType( String type )
	{
		
		for ( InformationData id : data )
		{
			if ( id.getType().equalsIgnoreCase(type) )
				return id;
		}
		return null;
	}
	
	
	public void addInfofmationData( String type, String Data, String Description )
	{
		InformationData id = new InformationData();
		id.setData( Data );
		id.setDescription(Description);
		id.setType( type );
		data.add( id );
	}
	
	ArrayList<InformationData> data  = new ArrayList<InformationData>();
	public class InformationData
	{
		public String getDescription()
		{
			return _description;
		}
		public void setDescription(String description) {
			_description = description;
		}
		public String getData() {
			return _data;
		}
		public void setData(String data) {
			_data = data;
		}
		public String getType() {
			return _type;
		}
		public void setType(String type) {
			_type = type;
		}
		String _description;
		String _data;
		String _type;
	}
	
	
	String _title;

	public String getTitle()
	{
		return _title;
	}

	public void setTitle(String title)
	{
		_title = title;
	}
	
	public int GetInformationCount()
	{
		return this.data.size();
	}
	
	public InformationData getInformationAt( int i )
	{
		return this.data.get( i );
	}
	
	public String toJSONObject()
	{
		
		StringBuilder sb = new StringBuilder();
		
		sb.append( "{" );
		sb.append("\"Information\":{");
		sb.append("\"Titel\":\"");
		sb.append( this.getTitle() );
		sb.append( "\"},\"InformationsData\":[" );
		
		for ( int i = 0; i < this.data.size(); i++ )
		{
			InformationData id = this.data.get( i );
			if ( i > 0 )
			{
				sb.append(",");
			}
			sb.append("{\"Description\":\"");
			sb.append( id.getDescription() );
			sb.append( "\",\"Data\":\"");
			sb.append( id.getData() );
			sb.append( "\",");
			//sb.append( "\"Information\":{\"Titel\":\"String content\"},");
			sb.append( "\"Type\":\"" );
			sb.append( id.getType() );
			sb.append( "\",\"Tags\":[{\"Tag\":\"MyTag\"},{\"Tag\":\"MyOtherTag\"} ]}");
		
		}
		sb.append("]}" );
		
		
		return sb.toString();
	}
}
